//
//  PTSBadgeButton.m
//  PTS80
//
//  Created by 黄杰 on 15/11/3.
//  Copyright © 2015年 黄杰. All rights reserved.
//

#import "PTSBadgeButton.h"

@implementation PTSBadgeButton

- (void)setHighlighted:(BOOL)highlighted
{
    
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.userInteractionEnabled = NO;
        self.hidden = YES;
        [self setBackgroundImage:[UIImage resizeWithImageName:@"PTS80.bundle/point_red"] forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont systemFontOfSize:11];
    }
    return self;
}

- (void)setBadgeValue:(NSString *)badgeValue
{
    _badgeValue = [badgeValue copy];
    
    if (badgeValue && [badgeValue integerValue] != 0) {
        self.hidden = NO;
        
        if ([badgeValue integerValue] >= 99) {
            // 设置文字
            [self setTitle:@"99" forState:UIControlStateNormal];
        } else {
            [self setTitle:badgeValue forState:UIControlStateNormal];
        }
        
    } else {
        self.hidden = YES;
    }
}

@end
